//
//  BK_OD_MatchNum_Cell.m
//  bestkeep
//
//  Created by TOPTEAM on 2017/2/28.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BK_OD_MatchNum_Cell.h"
#import "BK_OD_Color.h"
#import "BK_OD_Tool.h"
/**
 匹配个数
 */
@implementation BK_OD_MatchNum_Cell
{
    UILabel *_matchesText;
    UILabel *_matchesAmount;
    UILabel *_inventory;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initialize];
    }
    return self;
}

- (void)initialize
{
    /*
     * 出价匹配数
     */
    _matchesText = [[UILabel alloc] init];
    _matchesText.textColor=kOrderBlack1;
    _matchesText.font = UIFontCustom(15);
    [self.contentView addSubview:_matchesText];
    
    /*
     * 出价匹配的数字
     */
    _matchesAmount = [[UILabel alloc] init];
    _matchesAmount.textAlignment=NSTextAlignmentCenter;
    _matchesAmount.textColor=kOrderBlack1;
    _matchesAmount.font = UIFontCustom(18);
    [self.contentView addSubview:_matchesAmount];
    
    /*
     * 库存  %@
     */
    _inventory = [[UILabel alloc] init];
    _inventory.font = UIFontCustom(14);
    _inventory.textColor = kOrderLightGrey1;
    [self.contentView addSubview:_inventory];
    
    [self makeConstraints];
}

- (void)makeConstraints
{
    [_matchesText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(ApplicationBackGauge);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    
    /*
     * 匹配数的数字
     */
//    [_matchesAmount mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.centerY.mas_equalTo(self.contentView);
//    }];
    
    [_matchesAmount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        if(ScreenHeight>600) {
            make.centerX.mas_equalTo(self.contentView).offset(0);
        }else{
            make.centerX.mas_equalTo(self.contentView).offset(0);
        }
        
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(30);
    }];
    
    
    
    [_inventory mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView).offset(-ApplicationBackGauge);
        make.centerY.mas_equalTo(self.contentView);
    }];
}

- (void)fillData:(id)data
{
    if (!data) {
        return;
    }
    
    _matchesText.text = kOrderLocalizeString(@"BKOrderDDNumberOfMatches");
    _matchesAmount.text = data[@"numberOfMatches"];
    _inventory.text = [NSString stringWithFormat:@"库存  %@", data[@"inventory"]];
}

+ (CGFloat)computeHeight:(id)data{
//    return 60;
    return 66;
}
@end


